﻿using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;

namespace SalePartial.Model
{
    public class XPCompanyProductInfo
    {
        // Methods
        public XPCompanyProductInfo()
        {
            this._companyID = Guid.Empty;
            this._productName = string.Empty;
            this._productDescription = string.Empty;
            this._productPhotoTitle = string.Empty;
            this._productPhotoFile = string.Empty;
            this._createUserID = Guid.Empty;
            this._moderateUserID = Guid.Empty;
            this._comments = string.Empty;
            this._productID = Guid.NewGuid();
            this._createDate = DateTime.Now;
            this._lastUpdateDate = new DateTime(0x7ad565b72888000L);
            this._moderateDate = new DateTime(0x7ad565b72888000L);
        }

        public XPCompanyProductInfo(SqlDataReader reader)
        {
            this._companyID = Guid.Empty;
            this._productName = string.Empty;
            this._productDescription = string.Empty;
            this._productPhotoTitle = string.Empty;
            this._productPhotoFile = string.Empty;
            this._createUserID = Guid.Empty;
            this._moderateUserID = Guid.Empty;
            this._comments = string.Empty;
            this.LoadFromReader(reader);
        }

        //public XPCompanyProductInfo(Guid id)
        //{
        //    this._companyID = Guid.Empty;
        //    this._productName = string.Empty;
        //    this._productDescription = string.Empty;
        //    this._productPhotoTitle = string.Empty;
        //    this._productPhotoFile = string.Empty;
        //    this._createUserID = Guid.Empty;
        //    this._moderateUserID = Guid.Empty;
        //    this._comments = string.Empty;
        //    SqlDataReader reader = XPCompanyProductUtility.SelectReader(id);
        //    if (reader.Read()) {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    } else {
        //        if (!reader.IsClosed) {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPCompanyProducts does not exist.");
        //    }
        //}


        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                this._productID = reader.GetGuid(0);
                this._companyID = reader.GetGuid(1);
                this._productName = reader.GetString(2);
                if (!reader.IsDBNull(3))
                {
                    this._productDescription = reader.GetString(3);
                }
                this._productPhotoTitle = reader.GetString(4);
                this._productPhotoFile = reader.GetString(5);
                this._createUserID = reader.GetGuid(6);
                this._createDate = reader.GetDateTime(7);
                if (!reader.IsDBNull(8))
                {
                    this._lastUpdateDate = reader.GetDateTime(8);
                }
                if (!reader.IsDBNull(9))
                {
                    this._moderateStatus = reader.GetInt16(9);
                }
                if (!reader.IsDBNull(10))
                {
                    this._moderateDate = reader.GetDateTime(10);
                }
                if (!reader.IsDBNull(11))
                {
                    this._moderateUserID = reader.GetGuid(11);
                }
                if (!reader.IsDBNull(12))
                {
                    this._comments = reader.GetString(12);
                }
            }
        }


        // Properties
        public string Comments
        {
            get { return this._comments; }
            set { this._comments = value; }
        }

        public Guid CompanyID
        {
            get { return this._companyID; }
            set { this._companyID = value; }
        }

        public DateTime CreateDate
        {
            get { return this._createDate; }
            set { this._createDate = value; }
        }

        public Guid CreateUserID
        {
            get { return this._createUserID; }
            set { this._createUserID = value; }
        }

        public DateTime LastUpdateDate
        {
            get { return this._lastUpdateDate; }
            set { this._lastUpdateDate = value; }
        }

        public DateTime ModerateDate
        {
            get { return this._moderateDate; }
            set { this._moderateDate = value; }
        }

        public short ModerateStatus
        {
            get { return this._moderateStatus; }
            set { this._moderateStatus = value; }
        }

        public Guid ModerateUserID
        {
            get { return this._moderateUserID; }
            set { this._moderateUserID = value; }
        }

        public string ProductDescription
        {
            get { return this._productDescription; }
            set { this._productDescription = value; }
        }

        public Guid ProductID
        {
            get { return this._productID; }
            set { this._productID = value; }
        }

        public string ProductName
        {
            get { return this._productName; }
            set { this._productName = value; }
        }

        public string ProductPhotoFile
        {
            get { return this._productPhotoFile; }
            set { this._productPhotoFile = value; }
        }

        public string ProductPhotoTitle
        {
            get { return this._productPhotoTitle; }
            set { this._productPhotoTitle = value; }
        }


        // Fields
        private string _comments;
        private Guid _companyID;
        private DateTime _createDate;
        private Guid _createUserID;
        private DateTime _lastUpdateDate;
        private DateTime _moderateDate;
        private short _moderateStatus;
        private Guid _moderateUserID;
        private string _productDescription;
        private Guid _productID;
        private string _productName;
        private string _productPhotoFile;
        private string _productPhotoTitle;
    }
}
